"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
function createDirectory(dirPath) {
    const normalizedPath = path_1.default.normalize(dirPath);
    const pathParts = normalizedPath.split(path_1.default.sep);
    let currentPath = '';
    for (const part of pathParts) {
        if (!part)
            continue;
        currentPath = currentPath ? path_1.default.join(currentPath, part) : part;
        if (part.endsWith(':') && process.platform === 'win32') {
            continue;
        }
        if (!fs_1.default.existsSync(currentPath)) {
            try {
                fs_1.default.mkdirSync(currentPath);
            }
            catch (err) {
                if (err.code !== 'EEXIST') {
                    throw err;
                }
            }
        }
    }
}
exports.default = createDirectory;
